package com.zte.cl.service.task;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import us.codecraft.webmagic.Spider;

import com.zte.cl.model.SeedPage;
import com.zte.cl.parser.SeedPagePipeline;
import com.zte.cl.parser.SeedPageProcessor;

public class SeedPageTask implements Runnable {
	
	private static final Log log = LogFactory.getLog(SeedPageTask.class);

	private SeedPage seed;

	public SeedPageTask(SeedPage seed) {
		this.seed = seed;
	}

	@Override
	public void run() {
		Spider spider = Spider.create(new SeedPageProcessor(seed)).addUrl(seed.getUrl())
				.addPipeline(new SeedPagePipeline());
		spider.run();
		spider.close();
	}
}
